<!-- XHTML 1.0 Strict -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<meta name="author" content="Rachid Touzani" />
<meta name="keywords" content=" css, dropdowns, dropdown menu, drop-down, menu, navigation, nav, horizontal, vertical left-to-right, vertical right-to-left, horizontal linear, horizontal upwards, cross browser, internet explorer, ie, firefox, safari, opera, browser, lwis" />
<meta name="description" content="Clean, standards-friendly, modular framework for dropdown menus" />
<link href="../css/dropdown.vertical.css" media="screen" rel="stylesheet" type="text/css" />
<link href="../css/default.ultimate.css" media="screen" rel="stylesheet" type="text/css" />

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Heat Transfer Demo 3</title>
<link rel="stylesheet" type="text/css" href="../doxygen.css" />
<link rel="stylesheet" type="text/css" href="../tabs.css"  />
</head>

<body bgcolor="#FFFFFF" link="#FF0000" vlink="#FF00FF" alink="#FF00FF">
<p align="center"><a href="../index.html"><img src="../im/ofeli.gif" width="150" border="0"></a></p>

<center>
  <div id="cse" style="width: 60%;">Loading</div>
  <script src="http://www.google.com/jsapi" type="text/javascript"></script>
  <script type="text/javascript"> 
     google.load('search', '1', {language : 'en', style : google.loader.themes.SHINY});
     google.setOnLoadCallback(function() {
        var customSearchOptions = {};  var customSearchControl = new google.search.CustomSearchControl(
        '012396140824982761142:-qrywxcfi_o', customSearchOptions);
        customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
        customSearchControl.draw('cse');
     }, true);
   </script>
   <style type="text/css">
     .gsc-control-cse {
     font-family: Verdana, sans-serif;
     border-color: #DAE0E5;
     background-color: #DAE0E5;
   }
   .gsc-control-cse .gsc-table-result { font-family: Verdana, sans-serif; }
   input.gsc-input { border-color: #B6BEC5; }
   input.gsc-search-button {
     border-color: #B6BEC5;
     background-color: #D0D1D4;
   }
   .gsc-tabHeader.gsc-tabhInactive {
     border-color: #999999;
     background-color: #EEEEEE;
   }
   .gsc-tabHeader.gsc-tabhActive {
     border-color: #999999;
     background-color: #999999;
   }
   .gsc-tabsArea { border-color: #999999; }
   .gsc-webResult.gsc-result,
   .gsc-results .gsc-imageResult {
     border-color: #FFFFFF;
     background-color: #FFFFFF;
   }
   .gsc-webResult.gsc-result:hover,
   .gsc-imageResult:hover {
     border-color: #D2D6DC;
     background-color: #EDEDED;
   }
   .gsc-webResult.gsc-result.gsc-promotion:hover {
     border-color: #D2D6DC;
     background-color: #EDEDED;
   }
   .gs-webResult.gs-result a.gs-title:link,
   .gs-webResult.gs-result a.gs-title:link b,
   .gs-imageResult a.gs-title:link,
   .gs-imageResult a.gs-title:link b { color: #0568CD; }
   .gs-webResult.gs-result a.gs-title:visited,
   .gs-webResult.gs-result a.gs-title:visited b,
   .gs-imageResult a.gs-title:visited,
   .gs-imageResult a.gs-title:visited b { color: #0568CD; }
   .gs-webResult.gs-result a.gs-title:hover,
   .gs-webResult.gs-result a.gs-title:hover b,
   .gs-imageResult a.gs-title:hover,
   .gs-imageResult a.gs-title:hover b { color: #0568CD; }
   .gs-webResult.gs-result a.gs-title:active,
   .gs-webResult.gs-result a.gs-title:active b,
   .gs-imageResult a.gs-title:active,
   .gs-imageResult a.gs-title:active b { color: #0568CD; }
   .gsc-cursor-page { color: #0568CD; }
   a.gsc-trailing-more-results:link { color: #0568CD; }
   .gs-webResult .gs-snippet,
   .gs-imageResult .gs-snippet,
   .gs-fileFormatType { color: #5F6A73; }
   .gs-webResult div.gs-visibleUrl,
   .gs-imageResult div.gs-visibleUrl { color: #5F6A73; }
   .gs-webResult div.gs-visibleUrl-short { color: #5F6A73; }
   .gs-webResult div.gs-visibleUrl-short { display: none; }
   .gs-webResult div.gs-visibleUrl-long { display: block; }
   .gs-promotion div.gs-visibleUrl-short { display: none; }
   .gs-promotion div.gs-visibleUrl-long { display: block; }
   .gsc-cursor-box { border-color: #FFFFFF; }
   .gsc-results .gsc-cursor-box .gsc-cursor-page {
      border-color: #999999;
      background-color: #FFFFFF;
      color: #0568CD;
   }
   .gsc-results .gsc-cursor-box .gsc-cursor-current-page {
      border-color: #999999;
      background-color: #999999;
      color: #0568CD;
   }
   .gsc-webResult.gsc-result.gsc-promotion {
      border-color: #D2D6DC;
      background-color: #D0D1D4;
   }
   .gsc-completion-title { color: #0568CD; }
   .gsc-completion-snippet { color: #5F6A73; }
   .gs-promotion a.gs-title:link,
   .gs-promotion a.gs-title:link *,
   .gs-promotion .gs-snippet a:link { color: #0066CC; }
   .gs-promotion a.gs-title:visited,
   .gs-promotion a.gs-title:visited *,
   .gs-promotion .gs-snippet a:visited { color: #0066CC; }
   .gs-promotion a.gs-title:hover,
   .gs-promotion a.gs-title:hover *,
   .gs-promotion .gs-snippet a:hover { color: #0066CC; }
   .gs-promotion a.gs-title:active,
   .gs-promotion a.gs-title:active *,
   .gs-promotion .gs-snippet a:active { color: #0066CC; }
   .gs-promotion .gs-snippet,
   .gs-promotion .gs-title .gs-promotion-title-right,
   .gs-promotion .gs-title .gs-promotion-title-right *  { color: #333333; }
   .gs-promotion .gs-visibleUrl,
   .gs-promotion .gs-visibleUrl-short { color: #5F6A73; }
   </style>
</center>
</p>
&nbsp;

<div id="mainmenu">
<div class="text">

 <div class="tabs">
   <ul class="tablist">
   <li><a href="../index.html"><span>Home</span></a>
   <li><a href="../overview.html"><span>Overview</span></a>
   <li><a href="../html/index.html"><span>Class Documentation</span></a>
   <li><a href="../fformats.html"><span>File Formats</span></a>
   <li><a href="../tutorial.html"><span>Tutorial</span></a>
   <li class="current"><a href="../demos.html"><span>Demo Codes</span></a>
 </div>

 </div>
 </div>

&nbsp;
<p>
<h2>Heat Transfer Demo 3: A 3-D steady state diffusion code</h2>

<p><table border="2" cellpadding="2" cellspacing="0" >
<tr>
<td align="center" width="35"><a href="ttd2.html"><img src="../im/backward.gif" border="0"></a></td>
<td align="center" width="35"><a href="../demos.html"><img src="../im/top.gif" border="0"></a></td>
<td align="center" width="35"><a href="lelas2d.html"><img src="../im/forward.gif" border="0"></a></td>
</tr>
</table></p>

<p>
<SPAN class=TEXT>
This code is developed to solve 3-D steady-state (stationary) heat transfer problems.
The code is very similar to previous demo codes: <a href="stdc2.html">stdc2</a>
and <a href="ttd2.html">ttd2</a>.
</SPAN>

<li><SPAN class=TEXT>We construct an instance of class <span class=VAR>
<a href="../html/classOFELI_1_1IPF.html">IPF</a></span> to manage project data.
We extract useful information from this instance: An output flag to deal with output level
and a save flag to say if the solution is to be saved in file.
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>   IPF data("std3 - 1.0",argv[1]);
   int output_flag = data.getOutput();
   int save_flag = data.getSave();
</font></pre>
</td></tr></table>
</SPAN></p>

<li><SPAN class=TEXT>After outputting some information about the code, we declare an
instance of class <span class=VAR><a href="../html/classOFELI_1_1Mesh.html">Mesh</a></span>
with removing imposed boundary conditions: In fact, in view of using an iterative procedure
to solve the linear system. Penalty techniques are not efficient in this case.
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>   Mesh ms(data.getMeshFile(),true);
</font></pre>
</td></tr></table>
</SPAN></p>

<li><SPAN class=TEXT>In order to read various prescriptions (boundary conditions, heat sources, fluxes), we use the class <span class=VAR>
<a href="../html/classOFELI_1_1Prescription.html">Prescription</a></span>. The name
of the file containing these prescriptions is given in <span class=VAR>data.getDataFile()</span>

<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>   Prescription p(ms,data.getDataFile());
</font></pre>
</td></tr></table>
</SPAN></p>

<li><SPAN class=TEXT>The problem matrix is stored in sparse format in order to use
an iterative method to solve the linear system. We declare an instance of class
<span class=VAR><a href="../html/classOFELI_1_1SpMatrix.html">SpMatrix</a></span>.
We also declare vectors that will contain the solution and the right-hand side.
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>   SpMatrix&lt;double&gt; A(ms);
   Vect&lt;double&gt; u(ms.getNbEq()), b(ms.getNbEq());
</font></pre>
</td></tr></table>
</SPAN></p>

<li><span class=text>
Now we can read various prescriptions: we first instantiate vectors <span class=var>bc</span>
and <span class=VAR>body_f</span> that will contain respectively
Dirichlet boundary conditions and sources. Neumann boundary conditions
(imposed fluxes) are stored in a vector with mentionning that this one
is a <span class=VAR>SIDE_FIELD</span>.
Then we use the member function <span class=VAR>get</span> with various arguments to 
fill properly these vectors.
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>   Vect&lt;double&gt; bc(ms), body_f(ms), bound_f(ms,1,SIDE_FIELD);
   p.get(BOUNDARY_CONDITION,bc);
   p.get(BODY_FORCE,body_f);
   p.get(BOUNDARY_FORCE,bound_f,0);
</font></pre>
</td></tr></table>
</SPAN></p>

<li><SPAN class=TEXT>We define a loop over elements to compute and assemble
element arrays into the global matrix. Note the use of the macro <span class=VAR>
MeshElements</span> that updates the pointer <span class=VAR>theElement</span>
to current element at each step. For each element, we instantiate class
<span class=VAR><a href="../html/classOFELI_1_1DC3DT4.html">DC3DT4</a></span>
for thermal analysis in 3-D using 4-node tetrahedra,
we compute the diffusion contribution, the source term and update the right-hand
side with Dirichlet boundary conditions. Then we assemble element left-hand and
right-hand sides.
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>   MeshElements(ms) {
      DC3DT4 eq(theElement);
      eq.Diffusion();
      eq.BodyRHS(body_f);
      eq.updateBC(bc);
      eq.ElementAssembly(A);
      eq.ElementAssembly(b);
   }
</font></pre>
</td></tr></table>
</SPAN></p>

<li><SPAN class=TEXT>In this demo, we illustrate the use of side integrals
that take account for Neumann (flux) boundary conditions. This works 
exactly like for elements. We use for this the macro <span class=VAR>MeshSides</span>
that updates the <span class=VAR>
<a href="../html/classOFELI_1_1Side.html">Side</a></span> pointer <span class=VAR>theSide</span>.
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>   MeshSides(ms) {
      DC3DT4 eq(theSide);
      eq.BoundaryRHS(bound_f);
      eq.SideAssembly(b);
   }
</font></pre>
</td></tr></table>
</SPAN></p>

<li><SPAN class=TEXT>We can now solve the linear system of equations using the Conjugate
Gradient method preconditioned with the incomplete factorization preconditioner.
The parameter <span class=VAR>toler</span> is the tolerance value. On output it gives
the actual discrepancy between the two last iterations. 
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>   double toler = 1.e-8;
   int nb_it = CG(A,Prec&lt;double&gt;(A,ILU_PREC),b,u,1000,toler,0);
   cout << "Nb. of iterations: " << nb_it << endl;
</font></pre>
</td></tr></table>
</SPAN></p>

<li><SPAN class=TEXT>We want now to store the solution vector. Noting that the vector
<span class=VAR>b</span> does contain imposed boundary condition, we construct
a <span class=VAR><a href="../html/classOFELI_1_1Vect.html">Vect</a></span> instance and put in it the obtained solution as well as imposed degrees of freedom
by using the member function <span class=VAR>insertBC</span>.
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>   Vect&lt;double&gt; v(ms);
   v.insertBC(ms,u,bc);
</font></pre>
</td></tr></table>
</SPAN></p>

<li><SPAN class=TEXT>We next save the
obtained vector, after transforming it to a <span class=VAR><a href="../html/classOFELI_1_1NodeVect.html">NodeVect</a></span>
instance in the file <span class=VAR>data.getSaveFile()</span> by using the class
<span class=VAR><a href="../html/classOFELI_1_1IOField.html">IOField</a></span>.
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>   if (save_flag) {
      IOField pf(data.getSaveFile(),IOField::OUT);
      pf.put(NodeVect&lt;double&gt;(ms,v,"Temperature"));
   }
</font></pre>
</td></tr></table>
</SPAN></p>
</ul>


&nbsp;&nbsp;
<h2>An example</h2>

<SPAN class=TEXT>
Let us run this program with the data presented in the following project file:
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt;
&lt;OFELI_File&gt;
&lt;info&gt;
    &lt;title&gt;&lt;/title&gt;
    &lt;date&gt;&lt;/date&gt;
    &lt;author&gt;&lt;/author&gt;
&lt;/info&gt;
&lt;Project name="beam"&gt;
   &lt;mesh_file&gt;beam.m&lt;/mesh_file&gt;
   &lt;verbose&gt;1&lt;/verbose&gt;
   &lt;output&gt;0&lt;/output&gt;
   &lt;save&gt;1&lt;/save&gt;
&lt;/Project&gt;
&lt;Prescription&gt;
   &lt;BoundaryCondition code="1"&gt;1.0&lt;/BoundaryCondition&gt;
&lt;/Prescription&gt;
&lt;/OFELI_File&gt;</font></pre>
</td></tr></table></p>

<p>In summary, this file looks mainly like the one in the previous example.

<p><table align="center" border="2" cellpadding="2" cellspacing="0" >
<tr>
<td align="center" width="35"><a href="ttd2.html"><img src="../im/backward.gif" border="0"></a></td>
<td align="center" width="35"><a href="stdc2.html"><img src="../im/top.gif" border="0"></a></td>
<td align="center" width="35"><a href="lelas2d.html"><img src="../im/forward.gif" border="0"></a></td>
</tr>
</table>

&nbsp;
<div id="foot_bar">
        Copyright &copy; 1998-2018 Rachid Touzani&nbsp;
</div>

</body>
</html>
